package telas;

import Dao.Dao;
import Entidade.Evasor;
import Entidade.Usuario;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JOptionPane;

public class frmPrincipal extends javax.swing.JFrame {
    
    private final Usuario usuario;
    private final Dao dao = new Dao();
    
    public frmPrincipal(Usuario u) {
        usuario = u;        
        initComponents();
        lbOperador.setText(usuario.getNome());
        iconOk.setVisible(false);
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bgPistas = new javax.swing.ButtonGroup();
        bgAtender = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        rb0N = new javax.swing.JRadioButton();
        rb3R = new javax.swing.JRadioButton();
        rb4R = new javax.swing.JRadioButton();
        rb5R = new javax.swing.JRadioButton();
        rb2N = new javax.swing.JRadioButton();
        rb1N = new javax.swing.JRadioButton();
        rb11S = new javax.swing.JRadioButton();
        rb10S = new javax.swing.JRadioButton();
        rb9S = new javax.swing.JRadioButton();
        rb8R = new javax.swing.JRadioButton();
        rb7R = new javax.swing.JRadioButton();
        rb6R = new javax.swing.JRadioButton();
        rb21S = new javax.swing.JRadioButton();
        rb22N = new javax.swing.JRadioButton();
        rb31N = new javax.swing.JRadioButton();
        rb32N = new javax.swing.JRadioButton();
        rb33S = new javax.swing.JRadioButton();
        rb34S = new javax.swing.JRadioButton();
        jlPistas = new javax.swing.JLabel();
        jlPlaca = new javax.swing.JLabel();
        jftfPlaca = new javax.swing.JFormattedTextField();
        jlCategoria = new javax.swing.JLabel();
        jftfCategoria = new javax.swing.JFormattedTextField();
        jlCat = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jftfDataTransito = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        rbSim = new javax.swing.JRadioButton();
        rbNao = new javax.swing.JRadioButton();
        btRegistrarEvasao = new javax.swing.JButton();
        iconOk = new javax.swing.JLabel();
        cbPlacaNaoIdentificada = new javax.swing.JCheckBox();
        jLabel7 = new javax.swing.JLabel();
        jftfSequencial = new javax.swing.JFormattedTextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        lbOperador = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(820, 550));
        setPreferredSize(new java.awt.Dimension(820, 550));

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setMinimumSize(new java.awt.Dimension(779, 423));

        bgPistas.add(rb0N);
        rb0N.setText("0N");

        bgPistas.add(rb3R);
        rb3R.setText("3N");

        bgPistas.add(rb4R);
        rb4R.setText("4N");

        bgPistas.add(rb5R);
        rb5R.setText("5R");

        bgPistas.add(rb2N);
        rb2N.setText("2N");

        bgPistas.add(rb1N);
        rb1N.setText("1N");

        bgPistas.add(rb11S);
        rb11S.setText("11S");

        bgPistas.add(rb10S);
        rb10S.setText("10S");

        bgPistas.add(rb9S);
        rb9S.setText("9S");

        bgPistas.add(rb8R);
        rb8R.setText("8R");

        bgPistas.add(rb7R);
        rb7R.setText("7R");

        bgPistas.add(rb6R);
        rb6R.setText("6R");

        bgPistas.add(rb21S);
        rb21S.setText("21S");

        bgPistas.add(rb22N);
        rb22N.setText("22N");

        bgPistas.add(rb31N);
        rb31N.setText("31N");

        bgPistas.add(rb32N);
        rb32N.setText("32N");

        bgPistas.add(rb33S);
        rb33S.setText("33S");

        bgPistas.add(rb34S);
        rb34S.setText("34S");

        jlPistas.setText("Pistas:");

        jlPlaca.setText("Placa:");

        try {
            jftfPlaca.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("UUU####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jftfPlaca.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jftfPlaca.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jftfPlaca.setMinimumSize(new java.awt.Dimension(115, 35));
        jftfPlaca.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jftfPlacaMouseClicked(evt);
            }
        });
        jftfPlaca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftfPlacaActionPerformed(evt);
            }
        });

        jlCategoria.setText("Categoria:");

        jftfCategoria.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("00"))));
        jftfCategoria.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jftfCategoria.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jftfCategoria.setMinimumSize(new java.awt.Dimension(115, 35));
        jftfCategoria.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jftfCategoriaMouseClicked(evt);
            }
        });
        jftfCategoria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftfCategoriaActionPerformed(evt);
            }
        });

        jlCat.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jlCat.setText("CAT");

        jLabel1.setText("Data Hora Transito (\"DD/MM/AAAA HH:MM:SS\"):");

        jftfDataTransito.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss"))));
        jftfDataTransito.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jftfDataTransito.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jftfDataTransito.setMinimumSize(new java.awt.Dimension(115, 35));
        jftfDataTransito.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jftfDataTransitoFocusGained(evt);
            }
        });
        jftfDataTransito.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftfDataTransitoActionPerformed(evt);
            }
        });

        jLabel2.setText("Atender?");

        bgAtender.add(rbSim);
        rbSim.setText("Sim");
        rbSim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbSimActionPerformed(evt);
            }
        });

        bgAtender.add(rbNao);
        rbNao.setText("Não");

        btRegistrarEvasao.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        btRegistrarEvasao.setText("Registrar evasão");
        btRegistrarEvasao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRegistrarEvasaoActionPerformed(evt);
            }
        });

        iconOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/ok-icon.png"))); // NOI18N

        cbPlacaNaoIdentificada.setText("Placa não identificada");
        cbPlacaNaoIdentificada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbPlacaNaoIdentificadaActionPerformed(evt);
            }
        });

        jLabel7.setText("Sequencial:");

        jftfSequencial.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("0000"))));
        jftfSequencial.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jftfSequencial.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jftfSequencial.setMinimumSize(new java.awt.Dimension(58, 35));
        jftfSequencial.setPreferredSize(new java.awt.Dimension(58, 35));
        jftfSequencial.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jftfSequencialMouseClicked(evt);
            }
        });
        jftfSequencial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftfSequencialActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(rbSim)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rbNao))
                    .addComponent(jlPistas)
                    .addComponent(jlPlaca)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jftfPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cbPlacaNaoIdentificada))
                    .addComponent(jLabel1)
                    .addComponent(jftfDataTransito, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btRegistrarEvasao)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(iconOk))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(rb0N)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb1N)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb2N)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb3R)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb4R)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb5R)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb6R)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb7R)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb8R)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb9S)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb10S)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb11S)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb21S)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb22N)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb31N)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb32N)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb33S)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rb34S))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlCategoria)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jlCat)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jftfCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(19, 19, 19)
                                .addComponent(jLabel7))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jftfSequencial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(47, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jlPistas)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rb0N)
                    .addComponent(rb1N)
                    .addComponent(rb2N)
                    .addComponent(rb3R)
                    .addComponent(rb4R)
                    .addComponent(rb5R)
                    .addComponent(rb6R)
                    .addComponent(rb7R)
                    .addComponent(rb8R)
                    .addComponent(rb9S)
                    .addComponent(rb10S)
                    .addComponent(rb11S)
                    .addComponent(rb21S)
                    .addComponent(rb22N)
                    .addComponent(rb31N)
                    .addComponent(rb32N)
                    .addComponent(rb33S)
                    .addComponent(rb34S))
                .addGap(18, 18, 18)
                .addComponent(jlPlaca)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jftfPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbPlacaNaoIdentificada))
                        .addGap(18, 18, 18)
                        .addComponent(jlCategoria)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jlCat)
                            .addComponent(jftfCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jftfSequencial, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jftfDataTransito, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rbSim)
                            .addComponent(rbNao))
                        .addGap(18, 18, 18)
                        .addComponent(btRegistrarEvasao))
                    .addComponent(iconOk))
                .addContainerGap(127, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setText("CRT - Concessionária Rio Teresópolis");

        jLabel4.setText("SRE - Sistema de Registro de Evasão");

        jLabel5.setText("Desenvolvimento - Técnologia da Informação");

        jLabel6.setText("Operador: ");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel3))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbOperador)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel5)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(lbOperador))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btRegistrarEvasaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRegistrarEvasaoActionPerformed
            
        if(bgPistas.getSelection() == null){
            JOptionPane.showMessageDialog(rootPane, "Selecione a Pista!");
            return;
        }
        if(jftfPlaca.getText().equals("       ")){
            JOptionPane.showMessageDialog(rootPane, "Digite a placa!");
            jftfPlaca.requestFocus();
            return;
        }
        if(jftfCategoria.getText().equals("")){
            JOptionPane.showMessageDialog(rootPane, "Digite a Categoria!");
            jftfCategoria.requestFocus();
            return;
        }
        if(jftfSequencial.getText().equals("")){
            JOptionPane.showMessageDialog(rootPane, "Digite o Sequencial!");
            jftfSequencial.requestFocus();
            return;
        }
        if(jftfDataTransito.getText().equals("")){
            JOptionPane.showMessageDialog(rootPane, "Digite a data!");
            jftfDataTransito.requestFocus();
            return;
        }
        if(bgAtender.getSelection() == null){
            JOptionPane.showMessageDialog(rootPane, "Foi Antender?");
            return;
        }
        Evasor evasor = new Evasor();
        evasor.setPista(getSelectedButtonText(bgPistas));
        evasor.setPlaca(jftfPlaca.getText());
        evasor.setCategoria(jftfCategoria.getText());
        evasor.setDataEvasaoString(jftfDataTransito.getText());
        evasor.setAtender(getSelectedButtonText(bgAtender));
        evasor.setLoginUsuario(usuario.getLogin());
        evasor.setSeqTransito(Integer.parseInt(jftfSequencial.getText()));

        String pista = evasor.getPista();
        String placa = evasor.getPlaca();
        String dataEvasao = evasor.getDataEvasaoString();
        String cat = evasor.getCategoria();
        String atender = evasor.getAtender();
        String loginUsuario = evasor.getLoginUsuario();
        int SeqTransito = evasor.getSeqTransito();
            
        try {
            int x = dao.registraEvasao(pista, placa, dataEvasao, cat, atender, loginUsuario, SeqTransito);
            if( x != 0 ){
            } else {
                iconOk.setVisible(true);
                bgPistas.clearSelection();
                jftfPlaca.setText("");
                jftfCategoria.setText("");
                jftfDataTransito.setText("");
                bgAtender.clearSelection();
                cbPlacaNaoIdentificada.setSelected(false);
                jftfSequencial.setText("");
            }
        } catch (SQLException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(rootPane, ex);
        } catch (BadPaddingException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchPaddingException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalBlockSizeException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvalidKeyException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvalidAlgorithmParameterException ex) {
            Logger.getLogger(frmPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btRegistrarEvasaoActionPerformed

    private void jftfPlacaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftfPlacaActionPerformed
        jftfPlaca.selectAll();
        iconOk.setVisible(false);
    }//GEN-LAST:event_jftfPlacaActionPerformed

    private void jftfCategoriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftfCategoriaActionPerformed
        iconOk.setVisible(false);
    }//GEN-LAST:event_jftfCategoriaActionPerformed

    private void jftfDataTransitoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftfDataTransitoActionPerformed
        iconOk.setVisible(false);
    }//GEN-LAST:event_jftfDataTransitoActionPerformed

    private void rbSimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbSimActionPerformed
        iconOk.setVisible(false);
    }//GEN-LAST:event_rbSimActionPerformed

    private void jftfPlacaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jftfPlacaMouseClicked
        jftfPlaca.selectAll();
        iconOk.setVisible(false);
    }//GEN-LAST:event_jftfPlacaMouseClicked

    private void jftfCategoriaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jftfCategoriaMouseClicked
        iconOk.setVisible(false);
    }//GEN-LAST:event_jftfCategoriaMouseClicked

    private void jftfDataTransitoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jftfDataTransitoFocusGained
       iconOk.setVisible(false);
    }//GEN-LAST:event_jftfDataTransitoFocusGained

    private void cbPlacaNaoIdentificadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlacaNaoIdentificadaActionPerformed
        if(cbPlacaNaoIdentificada.isSelected()){
            jftfPlaca.setText("EVS0000");
            jftfPlaca.setEditable(false);
        } else {
            jftfPlaca.setText("");
            jftfPlaca.setEditable(true);
        }
    }//GEN-LAST:event_cbPlacaNaoIdentificadaActionPerformed

    private void jftfSequencialMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jftfSequencialMouseClicked
        jftfSequencial.selectAll();
        iconOk.setVisible(false);
    }//GEN-LAST:event_jftfSequencialMouseClicked

    private void jftfSequencialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftfSequencialActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jftfSequencialActionPerformed
    
    
    public String getSelectedButtonText(ButtonGroup buttonGroup) {
        for (Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements();) {
            AbstractButton button = buttons.nextElement();
            if (button.isSelected()) {
                return button.getText();
            }
        }
        return null;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup bgAtender;
    private javax.swing.ButtonGroup bgPistas;
    private javax.swing.JButton btRegistrarEvasao;
    private javax.swing.JCheckBox cbPlacaNaoIdentificada;
    private javax.swing.JLabel iconOk;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JFormattedTextField jftfCategoria;
    private javax.swing.JFormattedTextField jftfDataTransito;
    private javax.swing.JFormattedTextField jftfPlaca;
    private javax.swing.JFormattedTextField jftfSequencial;
    private javax.swing.JLabel jlCat;
    private javax.swing.JLabel jlCategoria;
    private javax.swing.JLabel jlPistas;
    private javax.swing.JLabel jlPlaca;
    private javax.swing.JLabel lbOperador;
    private javax.swing.JRadioButton rb0N;
    private javax.swing.JRadioButton rb10S;
    private javax.swing.JRadioButton rb11S;
    private javax.swing.JRadioButton rb1N;
    private javax.swing.JRadioButton rb21S;
    private javax.swing.JRadioButton rb22N;
    private javax.swing.JRadioButton rb2N;
    private javax.swing.JRadioButton rb31N;
    private javax.swing.JRadioButton rb32N;
    private javax.swing.JRadioButton rb33S;
    private javax.swing.JRadioButton rb34S;
    private javax.swing.JRadioButton rb3R;
    private javax.swing.JRadioButton rb4R;
    private javax.swing.JRadioButton rb5R;
    private javax.swing.JRadioButton rb6R;
    private javax.swing.JRadioButton rb7R;
    private javax.swing.JRadioButton rb8R;
    private javax.swing.JRadioButton rb9S;
    private javax.swing.JRadioButton rbNao;
    private javax.swing.JRadioButton rbSim;
    // End of variables declaration//GEN-END:variables
}
